<template>
  <navbar title="核销验票" :isBack="true"></navbar>
  <loading v-if="!list.length"></loading>
  <picture
    v-if="!list.length && isFirst"
    title="暂无数据"
    bg="#fff"
    imgPath="/static/image/18.png"
    imgHeight="200rpx"
    imgWidth="360rpx"
    :height="tools.clientTopHight(0)"
  ></picture>
  <ticketsList v-else :list="list"></ticketsList>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
import { getCheckList } from '@/service/api/user'
import tools from '@/utils/tools'
import ticketsList from '@/common/list/tickets.vue'

let params = ref({
  page: 1
})
let isFirst = ref(true)

let list = ref([])

// 核销列表
const getCheckListApi = async () => {
  const { msg } = await getCheckList({ page: params.value.page })
  isFirst.value = false
  if (!msg.data.length && params.value.page != 1) {
    return tools.showToast('暂无更多数据'), params.value.page--
  }
  list.value = [...list.value, ...msg.data]
}

onReachBottom(() => {
  params.value.page++
  // 核销列表
  getCheckListApi()
})

onLoad(() => {
  params.value.page = 1
  list.value = []
  // 核销列表
  getCheckListApi()
})
</script>

<style lang="scss" scoped></style>
